import { isFunction, isPromise } from "@/utils/is.js";

export const useLoadingStatus = (func) => {
  const loading = ref(false)

  if (!isFunction(func)) {
    loading.value = true
    if (isPromise(func)) {
      const pms = func()
      pms.finally(() => {
        loading.value = false
      })
    } else {
      func()
      loading.value = false
    }
  }

  return {
    loading
  }
}
